package com.css.zfzx.sjcj.modules.hddcWorkRegion.repository;

import com.css.zfzx.sjcj.modules.hddcWorkRegion.repository.entity.HddcWorkregionEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author zyb
 * @date 2020-11-30
 */
public interface HddcWorkregionRepository extends JpaRepository<HddcWorkregionEntity, String> {

    @Query(nativeQuery = true, value = "select * from hddc_Workregion where project_name in :projectIds")
    List<HddcWorkregionEntity> queryHddcWorkregionsByProjectId(List<String> projectIds);

    @Query(nativeQuery = true, value = "select * from hddc_Workregion where is_valid = '1'")
    List<HddcWorkregionEntity> findAll();

    @Query(nativeQuery = true, value = "select * from hddc_Workregion where task_name in :projectIds")
    List<HddcWorkregionEntity> queryHddcWorkregionsByTaskId(List<String> projectIds);

    @Query(nativeQuery = true, value = "select * from hddc_Workregion where create_user = :createID and province = :provinceName and city =:cityName and area =:areaName")
    List<HddcWorkregionEntity> queryHddcWorkregionByCreateuser(String createID,String provinceName,String cityName,String areaName);

    @Modifying
    @Query(nativeQuery = true, value = "update hddc_Workregion set is_valid = '0' where province = :provinceName and city =:cityName and area =:areaName and extends8 =:savefilename")
    void deleteFileData(String provinceName,String cityName,String areaName,String savefilename);
}
